
<?php 
// echo "<pre>";
// print_r($this->info->hinh_du_thi);
// echo "</pre>";
//echo $this->info->id_thi_sinh;
	$facebook = new Ishali_Facebook();
	$fb = $facebook->getFB();	
?>
        <div class="detail">
            
                <?php
                $images = json_decode($this->info->hinh_du_thi);
                $imageLink = APP_DOMAIN . '/public/images/' . $images[0];
                ?>
                <img id="hinhduthicuathisinh" class="anhduthi" src='<?php echo $imageLink; ?>'/>

					<?php
					if(count($images) > 1)
					{
						echo "<div class='show_more_img' style='padding-top:35px; position:relative'>";
							foreach ($images AS $img)
							{
								$img_url = APP_DOMAIN . '/public/images/' . $img;
								echo "<a onclick=\"showPreview('$img_url');return false\"><img src='$img_url' width='90px'></a>"	;
							}
						echo "</div>";
					}
					
					?>
			<div class="voidha">
			<p class="tents">
                <a TARGET = "_blank"  href="http://www.facebook.com/<?php echo $this->info->id_fb_thi_sinh; ?>">
                    <?php echo $this->info->ten_thi_sinh." (Mã: ".$this->info->mathisinh.")"; ?>
                </a>
            </p>
            

            <p class="luotbc"><span id="votingcount"><?php echo $this->info->luot_binh_chon; ?></span> Bình chọn</p>

            <?php if ($this->page->like_binh_chon == 1) {
				echo $_SESSION['haslike'];
				if($_SESSION['haslike'] == 1)
				{
				?>
				 <p><img src="<?php echo APP_DOMAIN;?>/application/layouts/tmpl2/images/ico_bc.png"/><a id="voting" href="javascript:void(0);">Bình chọn</a></p>
				<?php				
				}else
				{
						$imagelike = APP_DOMAIN . '/public/images/nutlike.png';
					echo  " Vui lòng  nhấn nút like  <img src='$imagelike'/> ở góc phải trên để bình chọn";
				}
			?>
               
            <?php }else
				{
			?>
			 <p class="binhchon"><img class="imgbc" src="<?php echo APP_DOMAIN; ?>/application/layouts/tmpl2/images/ico_bc.png"/><a id="voting" href="javascript:void(0);">Bình chọn</a></p>
			<?php
			}
			?>
			<p class="dangtuong">
				<a onclick="danglentuong()" href="javascript:;" >Đăng Lên Tường</a>
			</p>
			</div>
			
        </div>
		<div class="tenhanhtsinh">
			<?php
				$fql_b = 'SELECT name ,pic from user where uid = ' . $this->info->id_fb_thi_sinh;
				$ret_obj_b = $fb->api(array(
                               'method' => 'fql.query',
                               'query' => $fql_b,
                             ));
	
                    $hinhdaidien_fb =   $ret_obj_b[0]['pic'];
                    echo "<img class='imgts' src='$hinhdaidien_fb' />";
					$tenthisinh_fb =   $ret_obj_b[0]['name'];
					echo "<span class='htents'>$tenthisinh_fb</span>"
			?>
		
		</div>
		<div class="share">            

				<?php
			
				$pageid = $_SESSION['pageid'];
				$pages = 	$fb->api('/'.$pageid);
				$pages_name = $pages['name'];
				$pages_link = $pages['link'];
				$pages_category = $pages['category'];
				$pages_about = $pages['about'];
				$link_post_face=$pages_link."?sk=app_". APP_ID;
				$messages = "Bình chọn cho ". $this->info->ten_thi_sinh . " nhé! ";
				/*
				$fb->api('/me/feed', 'post', array(
				  'message' => $messages,
				  'link' => $link_post_face,
				  'name' => $pages_name,
				  'caption' => $pages_category,
				  'description' => $pages_about,
			  ));
			  */
				?>
				
				<a title="Chia sẻ lên Zing Me" target="_blank" href="http://link.apps.zing.vn/share?u="><img width='20px' height='20px' src="<?php echo APP_DOMAIN;?>/application/layouts/tmpl2/images/icon_zing.png"></a>
				<a title="Chia sẻ trên Google" target="_blank" href="https://plus.google.com/share?url="><img width='30px' height='20px' alt="Google +1" src="<?php echo APP_DOMAIN;?>/application/layouts/tmpl2/images/icon_google.jpg"></a>
				
				

				<?php
				$link_post_img = APP_DOMAIN . '/application/layouts/tmpl2/images/icon_fb.png';
				echo "<td align='right' class='post_facebook'>
				<a href='http://www.facebook.com/share.php?u=$link_post_face' id='facebook_wall' title='Share to Facebook' target='_blank' onclick='return vtlai_openbookmark(this);'><img width='20px' height='20px' src='$link_post_img'/></a></td>";	
				$idfriend = '100002280840454';
				?>
				<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fishali.com.vn&amp;send=false&amp;layout=button_count&amp;width=80&amp;show_faces=false&amp;font&amp;colorscheme=light&amp;action=like&amp;height=20&amp;appId=271410672984526" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:20px;" allowTransparency="true"></iframe>
				
				<!--
				<div id="fb-root"></div>
				<a href='#' onclick="FacebookInviteFriends();">Invite Friends</a>
				-->
				
			</div>

		
		<div class="ndduthi">
			<p class="title_nddt">Nội Dung Ảnh Dự Thi</p>
			<?php echo $this->info->gioi_thieu; ?>
		</div>
		<!--
		<span class="text_style2">Mô Tả</span>
        <div class="mota"><?php echo $this->info->mo_ta_bai_thi; ?></div>
		-->
<?php 

//$linkcomment = "http://chodatonline.com".$_SERVER["REQUEST_URI"];
	 $linkcomment = $link_post_face."&iduser=".$this->info->id_fb_thi_sinh;

//	 echo "<img src='https://graph.facebook.com/$idthisinh/picture' />";
	
?>
        <div class="comment">
            <!-- comment   -->    
			  <?php if ($this->page->like_binh_chon == 1) {
				
				if($_SESSION['haslike'] == 1)
				{
				//TODO: admin facebook comment
				?>
				<div class="fb-comments" data-href="<?php echo $linkcomment?>" data-width="750" data-num-posts="2"></div>
				<?php				
				}else
				{
						$imagelike = APP_DOMAIN . '/public/images/nutlike.png';
					echo  " Vui lòng  nhấn nút like  <img src='$imagelike'/> ở góc phải trên để bình luận";
				}
			?>
               
            <?php }else
				{
				//TODO: gan link page
			?>
			<div class="fb-comments" data-href="<?php echo $linkcomment?>" data-width="750" data-num-posts="2"></div>
			<?php
			}
			?>
        </div>



<script>
    //Change these values to style your modal popup
    var align = 'center';									//Valid values; left, right, center
    var ptop = 100; 											//Use an integer (in pixels)
    var width = 0; 										//Use an integer (in pixels)
    var padding = 10;										//Use an integer (in pixels)
    var backgroundColor = '#FFFFFF'; 						//Use any hex code
    var source = ''; 								//Refer to any page on your server, external pages are not valid e.g. http://www.google.co.uk
    var borderColor = '#333333'; 							//Use any hex code
    var borderWeight = 4; 									//Use an integer (in pixels)
    var borderRadius = 5; 									//Use an integer (in pixels)
    var fadeOutTime = 300; 									//Use any integer, 0 = no fade
    var disableColor = '#666666'; 							//Use any hex code
    var disableOpacity = 40; 								//Valid range 0-100
    var loadingImage = 'lib/release-0.0.1/loading.gif';		//Use relative path from this page

    source = '<table style="text-align: center; width: 380px;"><tr><td>[content]</td></tr></table>';
    
    //This method initialises the modal popup
    		
        
    $("#voting").click(function(){		
        if(true){
            var data ={"id":"<?php echo $this->info->id_thi_sinh ?>"};
            $.ajax({
                type: "POST",
                url: "<?php echo APP_DOMAIN; ?>/index/voting",
                data: data,
                dataType: "json"
            }).done(function(data) { 
                if(data.errorCode>=0){		
                    var voting = parseInt($("#votingcount").html());
                    ++voting;
                    $("#votingcount").html(voting);                    
                    $('#voting').unbind('click');
                }
                var msg = source.replace('[content]', data.message);
                modalPopup(align, ptop, width, padding, disableColor, disableOpacity, backgroundColor, borderColor, borderWeight, borderRadius, fadeOutTime, msg, loadingImage);
            });
        }		
    });
</script>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
<?php 
//	 $hinhthisinh = "https://graph.facebook.com/".$this->info->id_fb_thi_sinh ."/picture";
?>
	<script type="text/javascript">
   
	
	 function danglentuong() {
		FB.ui(
		  {
			method: 'feed',
			name: '<?php echo $pages_name ?>',
			link: '<?php echo $link_post_face ?>',
			caption: '<?php echo $pages_category ?>',
			 picture: 'http://fbrell.com/f8.jpg',
			message: '<?php echo $messages ?>',
			description: '<?php echo  $pages_about ?>'
		  },
		  function(response) {
			if (response && response.post_id) {
			  alert('Đã đăng lên tường');
			} 
		  }
		);
	}
	
	
	

	  </script>
	  
		<script>
			FB.init({
			appId:'<?php echo APP_ID ?>',
			cookie:true,
			status:true,
			xfbml:true
			});

			function FacebookInviteFriends()
			{
			FB.ui({
			method: 'apprequests',
			data: '<?php echo $link_post_face ?>',
			message: 'Your Message diaolog'
			});
			}
		</script>


		
			  
		<script>
			function showPreview(imagePath){
					document.getElementById('hinhduthicuathisinh').src = imagePath;					
				}
		</script>



